package 文件字节输出流;

import java.io.FileInputStream;
import java.io.IOException;

public class FileInputStreamTest03 {
    public static void main(String[] args) {
        FileInputStream fis = null;
        try {
//            相对路径是把当前工程作为根，开始找。
            fis = new FileInputStream("IO流/src/temp");
//            方法返回值：读到的字节数量(不是字节本身)
//            remp = abcdef
            byte[] bytes = new byte[4];
            int readCount = fis.read(bytes);
            System.out.println(readCount);  //第一次读到4个字节，返回4
            System.out.println(new String(bytes,0,readCount));
            readCount = fis.read(bytes);
            System.out.println(readCount);  //第二次读到2个字节，返回2
            System.out.println(new String(bytes,0,readCount));
            readCount = fis.read(bytes);
            System.out.println(readCount);  //第三次一个字节都读不到，返回-1
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fis != null) {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
